using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the NewCommercialLog class.
	/// </summary>
	[Serializable]
	public partial class NewCommercialLogCollection : ActiveList<NewCommercialLog, NewCommercialLogCollection> 
	{	   
		public NewCommercialLogCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the NewCommercialLog table.
	/// </summary>
	[Serializable]
	public partial class NewCommercialLog : ActiveRecord<NewCommercialLog>
	{
		#region .ctors and Default Settings
		
		public NewCommercialLog()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public NewCommercialLog(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public NewCommercialLog(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public NewCommercialLog(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("NewCommercialLog", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarNewCommercialLogID = new TableSchema.TableColumn(schema);
				colvarNewCommercialLogID.ColumnName = "NewCommercialLogID";
				colvarNewCommercialLogID.DataType = DbType.Int64;
				colvarNewCommercialLogID.MaxLength = 0;
				colvarNewCommercialLogID.AutoIncrement = true;
				colvarNewCommercialLogID.IsNullable = false;
				colvarNewCommercialLogID.IsPrimaryKey = true;
				colvarNewCommercialLogID.IsForeignKey = false;
				colvarNewCommercialLogID.IsReadOnly = false;
				colvarNewCommercialLogID.DefaultSetting = @"";
				colvarNewCommercialLogID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarNewCommercialLogID);
				
				TableSchema.TableColumn colvarCountryID = new TableSchema.TableColumn(schema);
				colvarCountryID.ColumnName = "CountryID";
				colvarCountryID.DataType = DbType.Byte;
				colvarCountryID.MaxLength = 0;
				colvarCountryID.AutoIncrement = false;
				colvarCountryID.IsNullable = true;
				colvarCountryID.IsPrimaryKey = false;
				colvarCountryID.IsForeignKey = false;
				colvarCountryID.IsReadOnly = false;
				colvarCountryID.DefaultSetting = @"";
				colvarCountryID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCountryID);
				
				TableSchema.TableColumn colvarRFDate = new TableSchema.TableColumn(schema);
				colvarRFDate.ColumnName = "RFDate";
				colvarRFDate.DataType = DbType.DateTime;
				colvarRFDate.MaxLength = 0;
				colvarRFDate.AutoIncrement = false;
				colvarRFDate.IsNullable = false;
				colvarRFDate.IsPrimaryKey = false;
				colvarRFDate.IsForeignKey = false;
				colvarRFDate.IsReadOnly = false;
				colvarRFDate.DefaultSetting = @"";
				colvarRFDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRFDate);
				
				TableSchema.TableColumn colvarTimeStart = new TableSchema.TableColumn(schema);
				colvarTimeStart.ColumnName = "TimeStart";
				colvarTimeStart.DataType = DbType.Int32;
				colvarTimeStart.MaxLength = 0;
				colvarTimeStart.AutoIncrement = false;
				colvarTimeStart.IsNullable = true;
				colvarTimeStart.IsPrimaryKey = false;
				colvarTimeStart.IsForeignKey = false;
				colvarTimeStart.IsReadOnly = false;
				colvarTimeStart.DefaultSetting = @"";
				colvarTimeStart.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeStart);
				
				TableSchema.TableColumn colvarTimeEnd = new TableSchema.TableColumn(schema);
				colvarTimeEnd.ColumnName = "TimeEnd";
				colvarTimeEnd.DataType = DbType.Int32;
				colvarTimeEnd.MaxLength = 0;
				colvarTimeEnd.AutoIncrement = false;
				colvarTimeEnd.IsNullable = true;
				colvarTimeEnd.IsPrimaryKey = false;
				colvarTimeEnd.IsForeignKey = false;
				colvarTimeEnd.IsReadOnly = false;
				colvarTimeEnd.DefaultSetting = @"";
				colvarTimeEnd.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeEnd);
				
				TableSchema.TableColumn colvarMediaCode = new TableSchema.TableColumn(schema);
				colvarMediaCode.ColumnName = "MediaCode";
				colvarMediaCode.DataType = DbType.Int32;
				colvarMediaCode.MaxLength = 0;
				colvarMediaCode.AutoIncrement = false;
				colvarMediaCode.IsNullable = true;
				colvarMediaCode.IsPrimaryKey = false;
				colvarMediaCode.IsForeignKey = false;
				colvarMediaCode.IsReadOnly = false;
				colvarMediaCode.DefaultSetting = @"";
				colvarMediaCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMediaCode);
				
				TableSchema.TableColumn colvarMediaType = new TableSchema.TableColumn(schema);
				colvarMediaType.ColumnName = "MediaType";
				colvarMediaType.DataType = DbType.String;
				colvarMediaType.MaxLength = 100;
				colvarMediaType.AutoIncrement = false;
				colvarMediaType.IsNullable = true;
				colvarMediaType.IsPrimaryKey = false;
				colvarMediaType.IsForeignKey = false;
				colvarMediaType.IsReadOnly = false;
				colvarMediaType.DefaultSetting = @"";
				colvarMediaType.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMediaType);
				
				TableSchema.TableColumn colvarProductID = new TableSchema.TableColumn(schema);
				colvarProductID.ColumnName = "ProductID";
				colvarProductID.DataType = DbType.Int32;
				colvarProductID.MaxLength = 0;
				colvarProductID.AutoIncrement = false;
				colvarProductID.IsNullable = true;
				colvarProductID.IsPrimaryKey = false;
				colvarProductID.IsForeignKey = false;
				colvarProductID.IsReadOnly = false;
				colvarProductID.DefaultSetting = @"";
				colvarProductID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProductID);
				
				TableSchema.TableColumn colvarCategoryID = new TableSchema.TableColumn(schema);
				colvarCategoryID.ColumnName = "CategoryID";
				colvarCategoryID.DataType = DbType.Int32;
				colvarCategoryID.MaxLength = 0;
				colvarCategoryID.AutoIncrement = false;
				colvarCategoryID.IsNullable = true;
				colvarCategoryID.IsPrimaryKey = false;
				colvarCategoryID.IsForeignKey = false;
				colvarCategoryID.IsReadOnly = false;
				colvarCategoryID.DefaultSetting = @"";
				colvarCategoryID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategoryID);
				
				TableSchema.TableColumn colvarSectorID = new TableSchema.TableColumn(schema);
				colvarSectorID.ColumnName = "SectorID";
				colvarSectorID.DataType = DbType.Int32;
				colvarSectorID.MaxLength = 0;
				colvarSectorID.AutoIncrement = false;
				colvarSectorID.IsNullable = true;
				colvarSectorID.IsPrimaryKey = false;
				colvarSectorID.IsForeignKey = false;
				colvarSectorID.IsReadOnly = false;
				colvarSectorID.DefaultSetting = @"";
				colvarSectorID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSectorID);
				
				TableSchema.TableColumn colvarSubSectorID = new TableSchema.TableColumn(schema);
				colvarSubSectorID.ColumnName = "SubSectorID";
				colvarSubSectorID.DataType = DbType.Int32;
				colvarSubSectorID.MaxLength = 0;
				colvarSubSectorID.AutoIncrement = false;
				colvarSubSectorID.IsNullable = true;
				colvarSubSectorID.IsPrimaryKey = false;
				colvarSubSectorID.IsForeignKey = false;
				colvarSubSectorID.IsReadOnly = false;
				colvarSubSectorID.DefaultSetting = @"";
				colvarSubSectorID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubSectorID);
				
				TableSchema.TableColumn colvarBrandID = new TableSchema.TableColumn(schema);
				colvarBrandID.ColumnName = "BrandID";
				colvarBrandID.DataType = DbType.Int32;
				colvarBrandID.MaxLength = 0;
				colvarBrandID.AutoIncrement = false;
				colvarBrandID.IsNullable = true;
				colvarBrandID.IsPrimaryKey = false;
				colvarBrandID.IsForeignKey = false;
				colvarBrandID.IsReadOnly = false;
				colvarBrandID.DefaultSetting = @"";
				colvarBrandID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBrandID);
				
				TableSchema.TableColumn colvarAdvertiserID = new TableSchema.TableColumn(schema);
				colvarAdvertiserID.ColumnName = "AdvertiserID";
				colvarAdvertiserID.DataType = DbType.Int32;
				colvarAdvertiserID.MaxLength = 0;
				colvarAdvertiserID.AutoIncrement = false;
				colvarAdvertiserID.IsNullable = true;
				colvarAdvertiserID.IsPrimaryKey = false;
				colvarAdvertiserID.IsForeignKey = false;
				colvarAdvertiserID.IsReadOnly = false;
				colvarAdvertiserID.DefaultSetting = @"";
				colvarAdvertiserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdvertiserID);
				
				TableSchema.TableColumn colvarVideoAudioImage = new TableSchema.TableColumn(schema);
				colvarVideoAudioImage.ColumnName = "VideoAudioImage";
				colvarVideoAudioImage.DataType = DbType.String;
				colvarVideoAudioImage.MaxLength = 300;
				colvarVideoAudioImage.AutoIncrement = false;
				colvarVideoAudioImage.IsNullable = true;
				colvarVideoAudioImage.IsPrimaryKey = false;
				colvarVideoAudioImage.IsForeignKey = false;
				colvarVideoAudioImage.IsReadOnly = false;
				colvarVideoAudioImage.DefaultSetting = @"";
				colvarVideoAudioImage.ForeignKeyTableName = "";
				schema.Columns.Add(colvarVideoAudioImage);
				
				TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
				colvarDateAdded.ColumnName = "DateAdded";
				colvarDateAdded.DataType = DbType.DateTime;
				colvarDateAdded.MaxLength = 0;
				colvarDateAdded.AutoIncrement = false;
				colvarDateAdded.IsNullable = false;
				colvarDateAdded.IsPrimaryKey = false;
				colvarDateAdded.IsForeignKey = false;
				colvarDateAdded.IsReadOnly = false;
				colvarDateAdded.DefaultSetting = @"";
				colvarDateAdded.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateAdded);
				
				TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
				colvarDateModified.ColumnName = "DateModified";
				colvarDateModified.DataType = DbType.DateTime;
				colvarDateModified.MaxLength = 0;
				colvarDateModified.AutoIncrement = false;
				colvarDateModified.IsNullable = false;
				colvarDateModified.IsPrimaryKey = false;
				colvarDateModified.IsForeignKey = false;
				colvarDateModified.IsReadOnly = false;
				colvarDateModified.DefaultSetting = @"";
				colvarDateModified.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateModified);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("NewCommercialLog",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("NewCommercialLogID")]
		public long NewCommercialLogID 
		{
			get { return GetColumnValue<long>("NewCommercialLogID"); }

			set { SetColumnValue("NewCommercialLogID", value); }

		}

		  
		[XmlAttribute("CountryID")]
		public byte? CountryID 
		{
			get { return GetColumnValue<byte?>("CountryID"); }

			set { SetColumnValue("CountryID", value); }

		}

		  
		[XmlAttribute("RFDate")]
		public DateTime RFDate 
		{
			get { return GetColumnValue<DateTime>("RFDate"); }

			set { SetColumnValue("RFDate", value); }

		}

		  
		[XmlAttribute("TimeStart")]
		public int? TimeStart 
		{
			get { return GetColumnValue<int?>("TimeStart"); }

			set { SetColumnValue("TimeStart", value); }

		}

		  
		[XmlAttribute("TimeEnd")]
		public int? TimeEnd 
		{
			get { return GetColumnValue<int?>("TimeEnd"); }

			set { SetColumnValue("TimeEnd", value); }

		}

		  
		[XmlAttribute("MediaCode")]
		public int? MediaCode 
		{
			get { return GetColumnValue<int?>("MediaCode"); }

			set { SetColumnValue("MediaCode", value); }

		}

		  
		[XmlAttribute("MediaType")]
		public string MediaType 
		{
			get { return GetColumnValue<string>("MediaType"); }

			set { SetColumnValue("MediaType", value); }

		}

		  
		[XmlAttribute("ProductID")]
		public int? ProductID 
		{
			get { return GetColumnValue<int?>("ProductID"); }

			set { SetColumnValue("ProductID", value); }

		}

		  
		[XmlAttribute("CategoryID")]
		public int? CategoryID 
		{
			get { return GetColumnValue<int?>("CategoryID"); }

			set { SetColumnValue("CategoryID", value); }

		}

		  
		[XmlAttribute("SectorID")]
		public int? SectorID 
		{
			get { return GetColumnValue<int?>("SectorID"); }

			set { SetColumnValue("SectorID", value); }

		}

		  
		[XmlAttribute("SubSectorID")]
		public int? SubSectorID 
		{
			get { return GetColumnValue<int?>("SubSectorID"); }

			set { SetColumnValue("SubSectorID", value); }

		}

		  
		[XmlAttribute("BrandID")]
		public int? BrandID 
		{
			get { return GetColumnValue<int?>("BrandID"); }

			set { SetColumnValue("BrandID", value); }

		}

		  
		[XmlAttribute("AdvertiserID")]
		public int? AdvertiserID 
		{
			get { return GetColumnValue<int?>("AdvertiserID"); }

			set { SetColumnValue("AdvertiserID", value); }

		}

		  
		[XmlAttribute("VideoAudioImage")]
		public string VideoAudioImage 
		{
			get { return GetColumnValue<string>("VideoAudioImage"); }

			set { SetColumnValue("VideoAudioImage", value); }

		}

		  
		[XmlAttribute("DateAdded")]
		public DateTime DateAdded 
		{
			get { return GetColumnValue<DateTime>("DateAdded"); }

			set { SetColumnValue("DateAdded", value); }

		}

		  
		[XmlAttribute("DateModified")]
		public DateTime DateModified 
		{
			get { return GetColumnValue<DateTime>("DateModified"); }

			set { SetColumnValue("DateModified", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(byte? varCountryID,DateTime varRFDate,int? varTimeStart,int? varTimeEnd,int? varMediaCode,string varMediaType,int? varProductID,int? varCategoryID,int? varSectorID,int? varSubSectorID,int? varBrandID,int? varAdvertiserID,string varVideoAudioImage,DateTime varDateAdded,DateTime varDateModified)
		{
			NewCommercialLog item = new NewCommercialLog();
			
			item.CountryID = varCountryID;
			
			item.RFDate = varRFDate;
			
			item.TimeStart = varTimeStart;
			
			item.TimeEnd = varTimeEnd;
			
			item.MediaCode = varMediaCode;
			
			item.MediaType = varMediaType;
			
			item.ProductID = varProductID;
			
			item.CategoryID = varCategoryID;
			
			item.SectorID = varSectorID;
			
			item.SubSectorID = varSubSectorID;
			
			item.BrandID = varBrandID;
			
			item.AdvertiserID = varAdvertiserID;
			
			item.VideoAudioImage = varVideoAudioImage;
			
			item.DateAdded = varDateAdded;
			
			item.DateModified = varDateModified;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(long varNewCommercialLogID,byte? varCountryID,DateTime varRFDate,int? varTimeStart,int? varTimeEnd,int? varMediaCode,string varMediaType,int? varProductID,int? varCategoryID,int? varSectorID,int? varSubSectorID,int? varBrandID,int? varAdvertiserID,string varVideoAudioImage,DateTime varDateAdded,DateTime varDateModified)
		{
			NewCommercialLog item = new NewCommercialLog();
			
				item.NewCommercialLogID = varNewCommercialLogID;
				
				item.CountryID = varCountryID;
				
				item.RFDate = varRFDate;
				
				item.TimeStart = varTimeStart;
				
				item.TimeEnd = varTimeEnd;
				
				item.MediaCode = varMediaCode;
				
				item.MediaType = varMediaType;
				
				item.ProductID = varProductID;
				
				item.CategoryID = varCategoryID;
				
				item.SectorID = varSectorID;
				
				item.SubSectorID = varSubSectorID;
				
				item.BrandID = varBrandID;
				
				item.AdvertiserID = varAdvertiserID;
				
				item.VideoAudioImage = varVideoAudioImage;
				
				item.DateAdded = varDateAdded;
				
				item.DateModified = varDateModified;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string NewCommercialLogID = @"NewCommercialLogID";
			 public static string CountryID = @"CountryID";
			 public static string RFDate = @"RFDate";
			 public static string TimeStart = @"TimeStart";
			 public static string TimeEnd = @"TimeEnd";
			 public static string MediaCode = @"MediaCode";
			 public static string MediaType = @"MediaType";
			 public static string ProductID = @"ProductID";
			 public static string CategoryID = @"CategoryID";
			 public static string SectorID = @"SectorID";
			 public static string SubSectorID = @"SubSectorID";
			 public static string BrandID = @"BrandID";
			 public static string AdvertiserID = @"AdvertiserID";
			 public static string VideoAudioImage = @"VideoAudioImage";
			 public static string DateAdded = @"DateAdded";
			 public static string DateModified = @"DateModified";
						
		}

		#endregion
	}

}

